<%@ page import="java.util.List" %>
<%@ page import="entity.Student" %><%--
  Created by IntelliJ IDEA.
  User: 93984
  Date: 2020/9/16
  Time: 20:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./css/bootstrap.min.css">
    <title>学生信息管理</title>
</head>
<%
    Object message = session.getAttribute("message");
    if(message!=null && !"".equals(message)){%>
<script type="text/javascript">
    alert("<%=message%>");
</script>

<%session.setAttribute("message", ""); } %>

<body style="padding:20px;" >

<div>
    <button class="btn btn-primary" onclick="addS()">新增</button>
    <form action="deletestudent" method="post" style="display: contents;">
        <input type="text" name="delete_id" id="delete_id_id" hidden>
        <input type="text" name="delete" value="delete" hidden>
        <button type="submit" class="btn btn-primary" id="delete_id">删除</button>
    </form>
    <button class="btn btn-primary" data-toggle="modal" data-target="#changest" data-action="change">编辑</button>
    <form action="students" method="get" style="display: contents">
        <button type="submit" class="btn btn-primary">查询</button>
        <!-- 搜索框 -->
        <input type="text" name="sid" id="query_id" placeholder="按照学号查询">
    </form>
</div>
<div>
    <table class="table table-hover table-responsive table-striped maintable" >
        <thead>
        <tr>
            <th>序号</th>
            <th>学号</th>
            <th>姓名</th>
            <th>性别</th>
            <th>出生日期</th>
            <th>邮箱</th>
            <th>备注</th>
        </tr>
        </thead>
        <tbody>
            <%
                List<Student> students = (List<Student>)request.getAttribute("students");
                for (Student st:students) {
            %>
            <tr>
                <td><input type="checkbox" name="check" id="<%=st.getId()%>"></td>
                <td><%=st.getSid()%></td>
                <td><%=st.getSname()%></td>
                <td><%=st.getSex()%></td>
                <td><%=st.getBirthday()%></td>
                <td><%=st.getEmail()%></td>
                <td><%=st.getRemarks()%></td>
            </tr>
        <% } %>
        </tbody>

    </table>
    <nav aria-label="Page navigation" style="position:fixed;top: 300px;left:40%">
        <ul class="pagination">
            <li>
                <a href="/stage4_module1/students?index=<%=request.getAttribute("previous")%>&perpage=3" aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>


            <%
                int count = (int) Math.ceil((long) request.getAttribute("studentscount") / 3.0);
                for (int i = 0; i < count; i++) {
            %>

            <li><a href="/stage4_module1/students?index=<%=i%>&perpage=3"><%=i + 1%>
            </a></li>
            <%
                }
            %>

            <li>
                <a href="/stage4_module1/students?index=<%=request.getAttribute("next")%>&perpage=3" aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                </a>
            </li>
        </ul>
    </nav>
</div>



<!-- 添加用户模态框 -->
<!-- 声明定义模态框组件 -->
<div class="modal" id="addStudent" data-backdrop="static">
    <!-- 窗口声明 -->
    <div class="modal-dialog">
        <!-- 内容声明 -->
        <div class="modal-content">
            <!-- 1.框的标题 -->
            <div class="modal-header">
                <button class="close" data-dismiss="modal">
                    <span>&times;</span>
                </button>
                <h4 class="modal-title">新增学生</h4>
            </div>
            <!-- 2.框内信息 -->
            <div class="modal-body">
                <form action="addstudent" method="post" id="ad">
                    <div class="form-group">
                        <label>学号</label>
                        <input type="text" class="form-control worknum" placeholder="请输入您的学号" name="sid" id="sid1">
                    </div>
                    <div class="form-group">
                        <label>姓名</label>
                        <input type="text" class="form-control username" placeholder="请输入您的姓名" name="sname" id="sname1">
                    </div>
                    <div class="form-group">
                        <label>性别</label>
                        <select class="form-control sex" name="sex" id="sex1">
                            <option value="男" selected name="sex">男</option>
                            <option value="女" name="sex">女</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>出生日期</label>
                        <input type="date" class="form-control birthday" placeholder="请输入您的出生日期" name="birthday" id="birthday1">
                    </div>
                    <div class="form-group">
                        <label>email</label>
                        <input type="email" class="form-control email" placeholder="请输入您的email" name="email" id="email1">
                    </div>
                    <div class="form-group">
                        <label>备注</label>
                        <input type="text" class="form-control remarks" placeholder="请输入您的备注" name="remarks" id="remark1">
                    </div>
                    <div class="form-group">
                        <input type="button" class="form-control" value="提交" onclick="adisnull()">
                    </div>

                </form>
            </div>
            <!-- 3.框的按钮 -->
            <%--<div class="modal-footer">
                <button class="btn btn-info" type="submit" >确定</button>
                <button class="btn btn-default" data-dismiss="modal">取消</button>
            </div>--%>
        </div>
    </div>
</div>

<div class="modal" id="changest" data-backdrop="static">
    <!-- 窗口声明 -->
    <div class="modal-dialog">
        <!-- 内容声明 -->
        <div class="modal-content">
            <!-- 1.框的标题 -->
            <div class="modal-header">
                <button class="close" data-dismiss="modal">
                    <span>&times;</span>
                </button>
                <h4 class="modal-title">修改学生</h4>
            </div>
            <!-- 2.框内信息 -->
            <div class="modal-body">
                <form action="changestudent" method="post" id="ct">
                    <input type="text" id="st_id" name="st_id" value="" hidden>
                    <div class="form-group">
                        <label>学号</label>
                        <input type="text" class="form-control worknum" placeholder="请输入您的学号" name="sid" id="sid2">
                    </div>
                    <div class="form-group">
                        <label>姓名</label>
                        <input type="text" class="form-control username" placeholder="请输入您的姓名" name="sname" id="sname2">
                    </div>
                    <div class="form-group">
                        <label>性别</label>
                        <select class="form-control sex" name="sex" id="sex2">
                            <option value="男" selected name="sex" id="man">男</option>
                            <option value="女" name="sex" id="women">女</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>出生日期</label>
                        <input type="date" class="form-control birthday" placeholder="请输入您的出生日期" name="birthday" id="birthday2">
                    </div>
                    <div class="form-group">
                        <label>email</label>
                        <input type="email" class="form-control email" placeholder="请输入您的email" name="email" id="email2">
                    </div>
                    <div class="form-group">
                        <label>备注</label>
                        <input type="text" class="form-control remarks" placeholder="请输入您的备注" name="remarks" id="remarks2">
                    </div>
                    <div class="form-group">
                        <input type="button" class="form-control" value="提交" onclick="ctisnull()">
                    </div>

                </form>
            </div>
            <!-- 3.框的按钮 -->
            <%--<div class="modal-footer">
                <button class="btn btn-info" type="submit" >确定</button>
                <button class="btn btn-default" data-dismiss="modal">取消</button>
            </div>--%>
        </div>
    </div>
</div>

<script type="text/javascript" src="./js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="./js/bootstrap.min.js"></script>
<script type="text/javascript" src="./js/student.js"></script>
</body>
</html>
